﻿<?php include("template/baglanti.php"); include ("template/upload.php"); include("template/header.php"); ?>
<link rel="stylesheet" type="text/css" href="css/main.css" />
<?php

$query = "SELECT * FROM categori ORDER BY categori_id";
$sql = mysql_query($query);


$ok = "";
$save = $_POST['save'];



if ($save) {



//Konu Ekleme Alanı




$categori_id = $_POST['categori_id'];
$Pdname = $_POST['Pdname'];
$Pdnamecn = $_POST['Pdnamecn'];
$Pdinfo = $_POST['Pdinfo'];
$Pdinfocn = $_POST['Pdinfocn'];
$Pdlang = $_POST['Pdlang'];
$Pdshowlist = $_POST['Pdshowlist'];
$Pdshow = $_POST['Pdshow'];
$Pdmodel = $_POST['Pdmodel'];
$Pdunit = $_POST['Pdunit'];
$Pdsize = $_POST['Pdsize'];
$Pdpower = $_POST['Pdpower'];
$Pdarea = $_POST['Pdarea'];
$Pdh = $_POST['Pdh'];

$dosyasmall = $_FILES['dosyasmall'];
if ( $dosyasmall['name'] != '') {
$Pdsphoto = upload_pic($dosyasmall);
}



@mysql_query("insert into products
(`categori_id`, `Pdname`, `Pdnamecn`, `Pdinfo`, `Pdinfocn`, `Pdsphoto` ,  `Pdlang` , `Pdshowlist` , `Pdshow`, `Pdmodel`, `Pdunit`, `Pdsize`, `Pdpower`, `Pdarea`, `Pdh` )
values ('$categori_id', '$Pdname', '$Pdnamecn', '$Pdinfo', '$Pdinfocn', '$Pdsphoto',   '$Pdlang', '$Pdshowlist','$Pdshow','$Pdmodel','$Pdunit','$Pdsize','$Pdpower','$Pdarea','$Pdh' )");

$ok = "done";
}

if(!$ok) {

?>

<div class="clear"> </div>

<div class="wrapper">

<div class="menu radius flt">
<?php include("./template/menu.php") ?>
</div>



<div class="wrapperInside radius flt">


<div class="wrapperInsideCapture">Sub Category Add </div>

<div class="wpForm">

<form class="validate" name="form1" method="post" id="save" enctype="multipart/form-data" >


	<div class="wpFormLabelBox">
	<div class="wpFormLabel">Choose Category</div>


<div class="wpFormSelecet radius">
	<select name="categori_id" class="turnintodropdown radius" >
  <option> All Category </option>
	<?php while($row = @mysql_fetch_assoc($sql)): ?>
	<option name="categori_id" value='<?=$row['categori_id']?>'> <?=$row['categori_name']?> </option>
	<?php endwhile; ?>
	</select>
	</div>
	</div>
	






<div class="wpFormLabelBox">
<div class="wpFormLabel"> Sub Category Name</div>
<div class="wpFormText radius"> <input name="Pdname" type="text"></div>
</div>


<div class="wpFormLabelBox">
<div class="wpFormLabel"> Sub Category (Chinese)Name</div>
<div class="wpFormText radius"> <input name="Pdnamecn" type="text"></div>
</div>


	<div class="wpFormLabelBox">
	<div class="wpFormLabel"> Product model (型号)</div>
	<div class="wpFormText radius"> <input name="Pdmodel" type="text" value="<?=$row['Pdmodel'];?>" /></div>
	</div>


	<div class="wpFormLabelBox">
	<div class="wpFormLabel"> Product unit (单位)</div>
	<div class="wpFormText radius"> <input name="Pdunit" type="text" value="<?=$row['Pdunit'];?>" /></div>
	</div>

	<div class="wpFormLabelBox">
	<div class="wpFormLabel"> Product power (发热量)</div>
	<div class="wpFormText radius"> <input name="Pdpower" type="text" value="<?=$row['Pdpower'];?>" /></div>
	</div>

	<div class="wpFormLabelBox">
	<div class="wpFormLabel"> Product size (尺寸)</div>
	<div class="wpFormText radius"> <input name="Pdsize" type="text" value="<?=$row['Pdsize'];?>" /></div>
	</div>

	<div class="wpFormLabelBox">
	<div class="wpFormLabel"> Product area (使用面积)</div>
	<div class="wpFormText radius"> <input name="Pdarea" type="text" value="<?=$row['Pdarea'];?>" /></div>
	</div>

<div class="wpFormLabelBox">
	<div class="wpFormLabel"> Product height (中心高度)</div>
	<div class="wpFormText radius"> <input name="Pdh" type="text" value="<?=$row['Pdh'];?>" /></div>
	</div>



<div class="wpFormLabelBox">
<div class="wpFormLabel "> Sub Category Detail</div>
<div class="wpFormText" style="display:block; height:100%;">
<textarea name="Pdinfo" id="textarea" cols="45"rows="5" /  class="mceEditor" ></textarea>
</div>
</div>

<div class="wpFormLabelBox">
<div class="wpFormLabel "> Sub Category (Chinese)Detail</div>
<div class="wpFormText" style="display:block; height:100%;">
<textarea name="Pdinfocn" id="textarea" cols="45"rows="5" /  class="mceEditor" ></textarea>
</div>
</div>



<div class="wpFormLabelBox">
<div class="wpFormLabel">Add Photo(250 x 250px)</div>
<input type="file" class="nicefileinput wpFormUpload" name="dosyasmall" id="fileField" />
</div>



<div class="wpFormLabelBox">
<div class="wpFormLabel">Order List </div>
<div class="wpFormSelecet radius">
<select name="Pdshowlist" class="turnintodropdown radius" >
<?php
for( $i=0; $i<=100; $i++ )
{
?>
<option name ="Pdshowlist" style="width:100px;">
<?php
echo $i;
echo "<br>"; ?>
</option>
<?php
}
?>
</select>
</div>
</div>

<div class="wpFormLabelBox">
<div class="wpFormLabel"> Language</div>
<div class="wpFormCheck">
<input id="radio1" type="radio" name="Pdlang" value="1" > <label for="radio1"> English </label>
</div>
</div>


<div class="wpFormLabelBox">
<div class="wpFormLabel">Show</div>
<div class="wpFormCheck">
<input id="radio1" type="radio" name="Pdshow" value="1" > <label> Yes </label>
<input id="radio1" type="radio" name="Pdshow" value="0" style="margin-left:24px;"> <label> No</label>
</div>
</div>


<div class="wpFormLabelBox">
<div class="wpFormButton"><input type="submit" name="save" id="save" value="Add" class="radius"></div>
</div>


</form>



</div>

<?php } if ($ok == "done"): ?>
<div class="welldone"><img src="images/ok.jpg" width="300" height="300"><br>
Your process well done !<br><a href="products.php">:: OK :: </a> </div>
<?php endif; ?>
</div>
</div>


<?php include("template/footer.php") ?>

<?php

function upload_pic($file)
{
$upload = new upload($file);
$new_name = substr(md5(time()),0,6).substr(md5(rand(0,100000)),0,6);
#big
$upload->file_new_name_body = $new_name;
$upload->process('../upload/products/');
if($upload->processed){
$upload->clean();
return $new_name.'.jpg';
}
return 'Hata:'.$upload->error;
}
?>
